package com.common.base.base;

import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.util.AttributeSet;
import android.view.View;

import androidx.appcompat.widget.AppCompatImageView;

@SuppressLint("AppCompatCustomView")
public class BaseImageView extends AppCompatImageView {

    public BaseImageView(Context context) {
        super(context);
    }

    public BaseImageView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public BaseImageView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    @Override
    protected void onAttachedToWindow() {
        try {
            super.onAttachedToWindow();
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onVisibilityAggregated(boolean isVisible) {
        try {
            super.onVisibilityAggregated(isVisible);
        } catch (Throwable e) {
            e.printStackTrace();
            if (isVisible) {
                try {
                    setVisibility(View.INVISIBLE);
                } catch (Throwable ex) {

                }
            }
        }
    }

    @Override
    protected void onDraw(Canvas canvas) {
        try {
            super.onDraw(canvas);
        } catch (Throwable e) {
            e.printStackTrace();
        }
    }
}
